def next(n):
    if (n % 2 == 0):
        return n / 2
    else:
        return (3 * n) + 1
    
cache = { 1 : 1}

def chain(n):
    if n in cache:
        return cache[n]
    else:
        nextn = next(n)
        length = 1 + chain(nextn)
        cache[n] = length
        return length

limit = 1000000

max = 0

for i in range(1, limit):
    length = chain(i)
    if length > max:
        max = length
        maxsrc = i
        print maxsrc, max
        
print maxsrc, max